﻿@using eCollabro.Client.Models.Content;
@using eCollabro.Client.Models.Core;
@using eCollabro.Common;
@using eCollabro.Web.Base;
@model BlogCategoryModel
@if (!Request.IsAjaxRequest())
{
    @Scripts.Render("~/bundles/blog")
}
@{
    List<PermissionEnum> userPermissions = (List<PermissionEnum>)ViewBag.UserPermissions;
    bool canEdit = userPermissions.Contains(PermissionEnum.EditContent);
    bool canDelete = userPermissions.Contains(PermissionEnum.DeleteContent);
    bool canAdd = userPermissions.Contains(PermissionEnum.AddContent);

    List<PageButton> pageButtons = new List<PageButton>();
    pageButtons.Add(new PageButton { Id = "btnBlogCategories", ButtonText = "Blog Categories", HideOnFooter = true, CssClass = "btn btn-success", Icon = "th-list", Method = "openBlogCategories()" });
    if ((canEdit && !Model.BlogCategoryId.Equals(0)) || (canAdd && Model.BlogCategoryId.Equals(0)))
    {
        pageButtons.Add(new PageButton { Id = "btnSave", ButtonText = "Save", HideOnHeader = true, CssClass = "btn btn-primary", Icon = "floppy-disk", Method = "saveBlogCategory()" });
    }
}
<div id="divBlogCategory" ng-controller="blogCategoryController" ng-init="loadBlogCategory(@Model.BlogCategoryId)">
    @Html.Partial("_PageHeader", new PageHeaderModel { ViewId = "BlogCategory", PageTitle = "Blog Category", ValidateForm = true, PageButtons = pageButtons })
    @using (Html.BeginForm("BlogCategory", "BlogCategory", FormMethod.Post, new { role = "form", id = "frmBlogCategory", @class = "form-horizontal" }))
    {

        @Html.AntiForgeryToken()
        <div class="form-group">
            @Html.LabelFor(m => m.BlogCategoryName, new { @class = "col-md-2 control-label" })
            <div class="col-md-5">
                @Html.TextBoxFor(m => m.BlogCategoryName, new { ng_model = "blogCategory.BlogCategoryName", @class = "form-control", maxlength = "50" })
                @Html.ValidationMessageFor(m => m.BlogCategoryName)
            </div>
        </div>
        <div class="form-group">
            @Html.LabelFor(m => m.BlogCategoryDescription, new { @class = "col-md-2 control-label" })
            <div class="col-md-5">
                @Html.TextAreaFor(m => m.BlogCategoryDescription, new { ng_model = "blogCategory.BlogCategoryDescription", @class = "form-control", maxlength = "255" })
            </div>
        </div>
        <div class="form-group">
            <div class="col-md-2"></div>
            <div class="col-md-5">
                <div class="checkbox">
                    @Html.CheckBoxFor(m => m.IsActive, new { ng_model = "blogCategory.IsActive" })
                    @Html.LabelFor(m => m.IsActive)
                </div>
            </div>
        </div>
        <div class="form-group">
            <div class="col-md-2"></div>
            <div class="col-md-5">
                <div class="checkbox">
                    @Html.CheckBoxFor(m => m.IsAnomynousAccess, new { ng_model = "blogCategory.IsAnomynousAccess" })
                    @Html.LabelFor(m => m.IsAnomynousAccess)
                </div>
            </div>
        </div>
        <div class="col-md-7">
            @Html.Partial("_PageFooter", new PageFooterModel
                {
                    PageButtons = pageButtons
                })
        </div>
    }
</div>